using System;
using System.Threading.Tasks;

namespace Services
{
    /// <summary>
    /// 缓存服务接口，定义缓存操作的基本功能
    /// </summary>
    public interface ICacheService
    {
        /// <summary>
        /// 获取或创建缓存项
        /// </summary>
        /// <typeparam name="T">缓存项的类型</typeparam>
        /// <param name="key">缓存键</param>
        /// <param name="factory">当缓存不存在时用于创建缓存项的工厂方法</param>
        /// <param name="expiration">缓存过期时间（可选）</param>
        /// <returns>缓存的值</returns>
        Task<T> GetOrCreateAsync<T>(string key, Func<Task<T>> factory, TimeSpan? expiration = null);

        /// <summary>
        /// 从缓存中移除指定键的项
        /// </summary>
        /// <param name="key">缓存键</param>
        Task RemoveAsync(string key);

        /// <summary>
        /// 检查指定键的缓存项是否存在
        /// </summary>
        /// <param name="key">缓存键</param>
        /// <returns>true表示存在，false表示不存在</returns>
        Task<bool> ExistsAsync(string key);
    }
} 